 mui.init();
var nativeWebview, imm, InputMethodManager;
var initNativeObjects = function() {
    if (mui.os.android) {
        var main = plus.android.runtimeMainActivity();
        var Context = plus.android.importClass("android.content.Context");
        InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
        imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
    } else {
        nativeWebview = plus.webview.currentWebview().nativeInstanceObject();
    }
};
var showSoftInput = function() {
    if (mui.os.android) {
        imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
    } else {
        nativeWebview.plusCallMethod({
            "setKeyboardDisplayRequiresUserAction": false
        });
    }
    setTimeout(function() {
       //此处可写具体逻辑设置获取焦点的input
       var inputElem = document.querySelector('#money');
              inputElem.focus(); 
    }, 200);
};
mui.plusReady(function(){
	initNativeObjects();
	showSoftInput();
	document.getElementById("money").focus();

	document.getElementById('red_packet').addEventListener("tap",function(){
					mui.openWindow({
						url: '../../pages/system/redpacket_help.html',
						id: '../../pages/system/redpacket_help.html'
			});
	});
});
function checkmoney() {
	try {
		document.getElementById('all_money').innerHTML = '0.000';
		var money = parseFloat(document.getElementById("money").value);
		if(isNaN(money))
		{
			return 0;
		}

/*		if (money < 0.001) {
			alert("最小个数为0.001");
			return 0;
		}
*/
		document.getElementById('all_money').innerHTML = money;
		if (money > 0) {
			mui('.mui-btn-danger.mui-btn-block')[0].style.opacity = 1;
		} else {
			mui('.mui-btn-danger.mui-btn-block')[0].style.opacity = 0.3;
		}

		return money;
	} catch (e) {

	}
	return 0;
}